// pages/member/rankingIndex/rankingIndex.js
var app = getApp();
Page({

  /**
	 * 页面的初始数据
	 */
  data: {
    //团队分红排行榜
    isTeamDividendShow: false,
    teamDividendTitle: "",
    teamDividendRankingLevel: "0",
    teamDividendRankingAction: "",
    imgPath: app.globalData.imgPath
  },

  /**
	 * 生命周期函数--监听页面加载
	 */
  onLoad: function(options) {
    this._getData();
  },

  /**
	 * 生命周期函数--监听页面初次渲染完成
	 */
  onReady: function() {

  },

  /**
	 * 生命周期函数--监听页面显示
	 */
  onShow: function() {

  },

  /**
	 * 生命周期函数--监听页面隐藏
	 */
  onHide: function() {

  },

  /**
	 * 生命周期函数--监听页面卸载
	 */
  onUnload: function() {

  },

  /**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
  onPullDownRefresh: function() {

  },

  /**
	 * 页面上拉触底事件的处理函数
	 */
  onReachBottom: function() {

  },

  /**
	 * 用户点击右上角分享
	 */
  onShareAppMessage: function() {

  },
  goteamDiv() {
    if (this.data.teamDividendRankingLevel == '1') {
      wx.navigateTo({
        url: '/mircoApp/ranking/rankingListFirst/rankingListFirst?action=' + this.data.teamDividendRankingAction +
					'&title=' + this.data.teamDividendTitle
      });
      //rankingListFirst
    } else {
      wx.navigateTo({
        url: '/mircoApp/ranking/rankingListSecond/rankingListSecond?action=' + this.data.teamDividendRankingAction +
					'&title=' + this.data.teamDividendTitle
      });
      //rankingListSecond
    }
  },
  //获取排行榜数据
  _getData() {
    let that = this;
    let urlStr = app.getNetAddresss("plugin.ranking.api.ranking.get-ranking-set");
    app._getNetWork({
      url: urlStr,
      success: function(resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setTeamDividendInfo(res.data); //团队分红排行榜
        } else {
          wx.showToast({
            icon: 'none',
            title: res.msg,
            duration: 1500
          });
        }
      },
      fail: function(res) {
        console.log(res);
      }
    });
  },
  //团队分红排行榜
  setTeamDividendInfo(data) {
    if (data.team_dividend == null || data.team_dividend == undefined || data.team_dividend == '') {
      this.setData({
        isTeamDividendShow: false
      });
      return;
    }
    this.setData({
      teamDividendRankingAction: data.team_dividend.ranking_level == "1" ? data.team_dividend.ranking_info_class : data
        .team_dividend.ranking_list_class,
      teamDividendRankingLevel: data.team_dividend.ranking_level,
      isTeamDividendShow: data.team_dividend.is_ranking == "1" ? true : false,
      teamDividendTitle: data.team_dividend.ranking_name
    });
  },
});
